//
//  SoundUtils.cpp
//  iFruitGame
//
//  Created by sxz on 2014/12/07.
//  Copyright 2014年 hibiya.tech@gmail.com . All rights reserved.
//

#include "SoundUtils.h"
#include "SimpleAudioEngine.h"

using namespace CocosDenshion;

void SoundUtils::buttonClick()
{
    SimpleAudioEngine::getInstance()->playEffect("button_click.caf");
}

void SoundUtils::playBackgroundMusic(char *filename, float volume, int musicCanPlay)
{
	 SimpleAudioEngine *sharedEngine = SimpleAudioEngine::getInstance();
	 sharedEngine->playBackgroundMusic(filename);
	 sharedEngine->setBackgroundMusicVolume(volume);
	 if (musicCanPlay==0)
	 {
		 sharedEngine->pauseBackgroundMusic();
	 }
}

void SoundUtils::playEffect(char *filename, float volume)
{
    SimpleAudioEngine *sharedEngine = SimpleAudioEngine::getInstance();
    sharedEngine->setEffectsVolume(volume);
    if (true){//[CommUtils getGameValue : @"SoundCanPlay"] == 1
        sharedEngine->playEffect(filename);
    }
}

void pauseBackgroundMusic(int musicCanPlay) {
    if(musicCanPlay == 1) {
        SimpleAudioEngine *sharedEngine = SimpleAudioEngine::getInstance();
        sharedEngine->pauseBackgroundMusic();
    }
}
